//
//  CalculateShapeLengthVisitor.swift
//  ArchitectGenerics
//
//  Created by 姚胜龙 on 2017/6/27.
//  Copyright © 2017年 姚胜龙. All rights reserved.
//

import UIKit

//计算周长的访问者
class CalculateShapeLengthVisitor: ShapeVisitorProtocol {

    var totalLength:Float = 0

    func visite(circle: CircleShape1) {
        self.totalLength = self.totalLength + 2 * 3.14 * circle.redius
    }

    func visite(square: SquareShape1) {
        self.totalLength = self.totalLength + square.length * 4
    }

    func visite(rectangle: RectangleShape1) {
        self.totalLength = self.totalLength + 2 * (rectangle.width + rectangle.height)
    }

}
